<template>
  <div class="func-comp-form">

    <ComponentGlobalSettingForm :id="id" :compConfigData="compConfigData"></ComponentGlobalSettingForm>

    <Tabs name="main_tabs" size="small" v-model="mainTabsValue">
      <TabPane name="main_tab" tab="main_tabs" label="主配置">

        <Collapse value="0">
          <Panel>
            常规配置
            <div slot="content">
              <Form :label-width="105">

                <FormItemPanel title="进度条配置">
                  <FormItem label="总值">
                    <InputNumber size="small" :min="1" :step="1" v-model="totalSteps"></InputNumber>
                  </FormItem>
                  <FormItem label="内半径">
                    <Input size="small" v-model="insideRadius" placeholder=""/>
                  </FormItem>
                  <FormItem label="外半径">
                    <Input size="small" v-model="outsideRadius" placeholder=""/>
                  </FormItem>
                  <FormItem label="起始颜色">
                    <PnColorPicker size="small" v-model="startColor" alpha recommend/>
                  </FormItem>
                  <FormItem label="结束颜色">
                    <PnColorPicker size="small" v-model="stopColor" alpha recommend/>
                  </FormItem>
                  <FormItem label="背景色">
                    <PnColorPicker size="small" v-model="innerStrokeColor" alpha recommend/>
                  </FormItem>
                </FormItemPanel>

                <FormItemPanel title="提示文本">
                  <FormItem label="显示">
                    <i-switch v-model="showLabel">
                      <span slot="open"></span>
                      <span slot="close"></span>
                    </i-switch>
                  </FormItem>
                  <FormItem label="前缀">
                    <Input size="small" v-model="prefixText"/>
                  </FormItem>
                  <FormItem label="后缀">
                    <Input size="small" v-model="suffixText"/>
                  </FormItem>
                  <FormItem label="颜色">
                    <PnColorPicker size="small" v-model="textColor" alpha recommend/>
                  </FormItem>
                  <FormItem label="字体大小">
                    <InputNumber size="small" :max="1000" :min="1" v-model="textFontSize"></InputNumber> px
                  </FormItem>
                </FormItemPanel>
              </Form>
            </div>
          </Panel>
          <Panel v-if="chartOption.title">
            标题
            <ShowToggle class="float-right" v-model="chartOption.title.show"></ShowToggle>
            <div slot="content">
              <EchartsTitleConfigForm v-model="chartOption.title"></EchartsTitleConfigForm>
            </div>
          </Panel>
          <Panel>
            其他
            <div slot="content">
              <EchartsOtherConfigForm v-model="compConfigData"></EchartsOtherConfigForm>
            </div>
          </Panel>
        </Collapse>

      </TabPane>
      <TabPane name="extend_tab" tab="main_tabs" label="扩展配置">
        <Container v-if="mainTabsValue == 'extend_tab'">
          <CustomOptionDocument :componentId="id"></CustomOptionDocument>
          <CodeEditor v-model="customOption" mode="json"></CodeEditor>
          <EchartsSpreadingCodeForm v-model="echartsSpreadingCode"></EchartsSpreadingCodeForm>
        </Container>
      </TabPane>
      <TabPane name="datasource_tab" tab="main_tabs" label="数据源">
        <DatasourceState v-if="mainTabsValue == 'datasource_tab'" targetComp="PercentPieChart"></DatasourceState>
      </TabPane>
      <TabPane name="interaction_tab" tab="main_tabs" label="交互">
        <Container v-if="mainTabsValue == 'interaction_tab'">
          <InteractionReceive></InteractionReceive>
          <CustomJsDocument></CustomJsDocument>
          <FormItemPanel title="初始化运行脚本">
            <CodeEditor v-model="customGlobalJsCode"></CodeEditor>
          </FormItemPanel>
        </Container>
      </TabPane>
    </Tabs>


  </div>
</template>

<script>

  import FuncCompFormMixin from '@/mixin/FuncCompFormMixin'

  import { createHelpers } from 'vuex-map-fields';

  const { mapFields } = createHelpers({
    getterType: 'designer/getLayoutItem',
    mutationType: 'designer/updateLayoutItem',
  });

  export default {
    name: 'PercentPieChartForm',
    mixins: [FuncCompFormMixin],
    data() {
      return {

      }
    },
    mounted() {
      console.log(this.chartOption)
    },
    methods: {},
    computed: {
      ...mapFields({

        chartOption: 'component.compConfigData.chartOption',

        insideRadius: 'component.compConfigData.chartOption.insideRadius',
        outsideRadius: 'component.compConfigData.chartOption.outsideRadius',

        totalSteps: 'component.compConfigData.chartOption.totalSteps',
        startColor: 'component.compConfigData.chartOption.startColor',
        stopColor: 'component.compConfigData.chartOption.stopColor',
        innerStrokeColor: 'component.compConfigData.chartOption.innerStrokeColor',

        showLabel: 'component.compConfigData.chartOption.showLabel',
        prefixText: 'component.compConfigData.chartOption.prefixText',
        suffixText: 'component.compConfigData.chartOption.suffixText',
        textColor: 'component.compConfigData.chartOption.textColor',
        textFontSize: 'component.compConfigData.chartOption.textFontSize',

      })
    }
  }
</script>

<style scoped>

</style>
